/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frm.billingAndPaymentProcessing.managedbean;

import frm.billingAndPaymentProcessing.entity.IncomingBillEntity;
import frm.billingAndPaymentProcessing.session.IncomingBillSessionBean;
import java.io.IOException;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.ToggleEvent;

/**
 *
 * @author xhx
 */
@ManagedBean
@ViewScoped
public class ViewAllIncomingBillRecordManagedBean {
    private IncomingBillEntity incomingBillEntity;
@EJB
IncomingBillSessionBean incomingBillSessionBean;
    /** Creates a new instance of ViewAllIncomingBillRecordManagedBean */
    public ViewAllIncomingBillRecordManagedBean() {
        
    }
      public List<IncomingBillEntity> getAllIncomingBills(){
      List<IncomingBillEntity> billList  = incomingBillSessionBean.getAllIncomingBills();
      return billList;
    }
    public List<IncomingBillEntity> getAolishedIncomingBills(){
        List<IncomingBillEntity> abillList = incomingBillSessionBean.getAbolishedBills();
        return abillList;
    }
    public void viewIncomingBill(IncomingBillEntity selecteIncomingBillEntity) throws IOException{
       incomingBillEntity = selecteIncomingBillEntity;
       FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("message", "viewAll");
       FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("incomingBillEntity", incomingBillEntity);
       FacesContext.getCurrentInstance().getExternalContext().redirect("displayIncomingBill.xhtml");  
    }
     public void handleToggle(ToggleEvent event) {
        FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Fieldset Toggled", "Visibility:" + event.getVisibility());

        FacesContext.getCurrentInstance().addMessage(null, msg);
    }
    
//    public void updateInvoice(IncomingBillEntity selectedIncomingBillEntity) throws IOException{
//        incomingBillEntity = selectedIncomingBillEntity;
//       FacesContext.getCurrentInstance().getExternalContext().getFlash().put("incomingBillEntity", incomingBillEntity);
//       FacesContext.getCurrentInstance().getExternalContext().redirect("updateInvoice.xhtml");  
//    }

    public IncomingBillEntity getIncomingBillEntity() {
        return incomingBillEntity;
    }

    public void setIncomingBillEntity(IncomingBillEntity incomingBillEntity) {
        this.incomingBillEntity = incomingBillEntity;
    }
}
